/*
 * SystemPropertyControl.java
 *
 * Created on 14 September 2004, 08:59
 * Copyright (C) 2004, Velocityme Partnership
 */

package com.velocityme.client.gui.loginhistory;

import com.velocityme.client.gui.exception.ExceptionWindow;
import com.velocityme.client.utility.StatelessRemoteClientSessionUtil;
import com.velocityme.interfaces.KeySession;
import com.velocityme.utility.InvalidKeyException;
import com.velocityme.utility.LicenceKey;
import com.velocityme.utility.PermissionDeniedException;
import java.rmi.RemoteException;
import java.util.Collection;
import java.util.Set;
import javax.ejb.CreateException;
import javax.naming.NamingException;

/**
 *
 * @author  Robert Crida Work
 */
public class LoginHistoryControl extends javax.swing.JPanel {
    
    private KeySession m_key;
    private LoginHistoryDisplay m_loginHistoryDisplay;
    
    /** Creates new form SystemPropertyControl */
    public LoginHistoryControl(KeySession p_key, Set p_setPermissions) {
        m_key = p_key;
        initComponents();
        m_loginHistoryDisplay = new LoginHistoryDisplay();
        updateLoginHistoryDisplay();
        add(m_loginHistoryDisplay, java.awt.BorderLayout.CENTER);
    }
    
    private void updateLoginHistoryDisplay() {
        try {
            Collection loginValues = StatelessRemoteClientSessionUtil.getSession().getAllUserLoginValues(m_key);
            m_loginHistoryDisplay.setLoginValues(loginValues);
        }
        catch(RemoteException e) {
            ExceptionWindow.showError(e);
        }
        catch(NamingException e) {
            ExceptionWindow.showError(e);
        }
        catch(CreateException e) {
            ExceptionWindow.showError(e);
        }
        catch(InvalidKeyException e) {
            ExceptionWindow.showError(e);
        }
        catch(PermissionDeniedException e) {
            ExceptionWindow.showError(e);
        }
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents

        setLayout(new java.awt.BorderLayout());

    }//GEN-END:initComponents
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
    
}
